home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <stdlib.h>
- #include <dos.h>
- #include "define.h"
-
- #ifdef DEBUG
- main(int argc, char *argv[])
- {
- long int sec;
-
- if (argc > 1) {
- printf("input is %s\n", argv[1]);
- sec = atol(argv[1]);
- printf("Seek %lx sector\n", sec);
- printf("return is %x\n", cdr_seek(0, sec));
- }
- }
- #endif
-
- /* 指定位置へのシーク(論理セクタ指定) */
- /*
- * decice_no: device number (Towns CD-ROM -> 0)
- * sector_number: 論理セクター番号
- * return: 0 -> 正常終了, 0以外 -> エラー
- */
- int cdr_seek(int device_no, long int sector_number)
- {
- union REGS reg;
-
- reg.h.ah = 0x04;
- reg.h.al = (0xC0 | (u_char) device_no);
- reg.x.cx = 0x0000;
- reg.h.cl = (u_char) ((u_long) sector_number) >> 16; /* High */
- reg.x.dx = (u_int) (sector_number & 0x00ffff); /* Low */
- #ifdef DEBUG
- printf("sector number: High is %x, Low is %x\n", reg.h.cl, reg.x.dx);
- #endif
- int86(0x93, ®, ®);
-
- if (reg.h.ah == 0) {
- return 0;
- } else if (reg.h.ah == 0x02) { /* device number error */
- return DEVERR;
- } else if (reg.h.ah == 0x10) { /* cd-da plaing */
- return DEVPLY;
- } else { /* (reg.h.ah == 0x80) hard ware error */
- return reg.x.cx;
- }
- }
-
-